package it.polimi.swKnights.SWIMv2.ejb.entityBeans;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

/**
 * Entity implementation class for Entity: Friendship
 * 
 */
@Entity
@IdClass(FriendshipPk.class)
public class Friendship implements Serializable
{
	@Id
	@Column(name = "userName1", insertable = false, updatable = false)
	private String userName1;

	@Id
	@Column(name = "userName2", insertable = false, updatable = false)
	private String userName2;

	@ManyToOne
	@JoinColumn(name = "userName1", insertable = false, updatable = false)
	private RegisteredUser user1;

	@ManyToOne
	@JoinColumn(name = "userName2", insertable = false, updatable = false)
	private RegisteredUser user2;

	private boolean direct;

	/*
	 * Serial Version ID
	 */

	private static final long serialVersionUID = 1L;

	/*
	 * Constructors
	 */

	public Friendship()
	{
		super();
	}

	public Friendship(RegisteredUser userName1, RegisteredUser userName2,
			boolean direct)
	{
		this.userName1 = userName1.getUserName();
		this.userName2 = userName2.getUserName();
		this.direct = direct;
	}

	/*
	 * Getters and setters
	 */

	public boolean isDirect()
	{
		return this.direct;
	}

	public RegisteredUser getUser1()
	{
		return user1;
	}

	public void setUser1(RegisteredUser user1)
	{
		this.user1 = user1;
	}

	public RegisteredUser getUser2()
	{
		return user2;
	}

	public void setUser2(RegisteredUser user2)
	{
		this.user2 = user2;
	}

	public void setDirect(boolean direct)
	{
		this.direct = direct;
	}

}
